home *** CD-ROM | disk | FTP | other *** search
- ' +----------------------------------------------------------------------+
- ' | |
- ' | PBClone Copyright (c) 1990-1994 Thomas G. Hanlin III |
- ' | |
- ' +----------------------------------------------------------------------+
-
-
- DECLARE FUNCTION AscM% (St$, BYVAL Posn%)
- DECLARE FUNCTION UpcaseI% (BYVAL Ch%)
-
- FUNCTION FormatPhone$ (RawSt$)
-
- '--- toss any characters that aren't alphanumeric, 'n' also Q and Z
- st$ = ""
- FOR tmp% = 1 TO LEN(RawSt$)
- ch% = UpcaseI%(AscM%(RawSt$, tmp%))
- IF ch% >= 48 AND ch% <= 57 OR ch% >= 65 AND ch% < 90 AND ch% <> 81 THEN
- st$ = st$ + CHR$(ch%)
- END IF
- NEXT
-
- '--- format the result based on the string length
- IF LEN(st$) = 11 AND LEFT$(st$, 1) = "1" THEN
- st$ = MID$(st$, 2)
- END IF
- SELECT CASE LEN(st$)
- CASE 4
- FormatPhone$ = st$
- CASE 7
- FormatPhone$ = LEFT$(st$, 3) + "-" + RIGHT$(st$, 4)
- CASE 10
- FormatPhone$ = "(" + LEFT$(st$, 3) + ") " + MID$(st$, 4, 3) + "-" + RIGHT$(st$, 4)
- CASE ELSE
- FormatPhone$ = ""
- END SELECT
- END FUNCTION
-